#include <fstream>
#include <pthread.h>
#include "common_def.h"

namespace andrew{
	namespace tools{
		namespace log
		{

			class log_writer
			{
				private:
					unsigned int log_max_line;
					unsigned int err_case_count;
					unsigned int succ_case_count;
					std::ofstream file_writer;
					pthread_mutex_t log_mtx;
					time_t iCurrTime;
					struct tm stCurrTime;
					struct timeval ms;
					char sz_file_name[MAX_FILE_PATH];
					char sz_log_path[MAX_FILE_PATH];
				public:
					log_writer();
					virtual ~log_writer();
				public:
					int init(unsigned int _tmp_max_line,const char* _tmp_log_path);
					int write(const char* _tmp_log);
					int record_time_begin(const char* _tmp_log);
					int record_time_end(const char* _tmp_log);
				private:
					char* logtime();

			};
		}
	}
}
